#include<iostream>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL arr[N];
int n, k;
int cnt;
int main()
{
	cin >> n >> k;
	priority_queue<int, vector<int>, greater<int>>q;

	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		q.push(x);
	}
	while (k >= 0) {
		int x = q.top();
		q.pop();
		if (k >= x) {
			k -= x;
			x *= 2;
			q.push(x);
			cnt++;
		}
		else {
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}